<template>
  <el-container class="home_container">
    <!--     头部 -->
    <el-header>
      <div>
        <span>亿学伴管理系统</span>
      </div>
      <el-button type="info" >退出</el-button>
    </el-header>
    <el-container>
      <!--侧边栏        -->
      <el-aside :width="isCollapse?'64px':'200px'">
        <div class="toggle-button" @click="toggleCollapse">|||</div>
        <el-menu
            background-color="#333744"
            text-color="#fff"
            active-text-color="#409EFF"
            :collapse="isCollapse"
            :collapse-transition="false"
            :router="true"
            :default-active="activePath">
          <el-submenu index="/">
            <template slot="title">
              <i class="el-icon-user-solid"></i>
              <span>信息管理</span>
            </template>
            <!--              二级菜单-->
            <el-menu-item index="/M_User" @click="saveNavState('/M_User')">
              <template slot="title">
                <i class="el-icon-s-custom"></i>
                <span>用户信息</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/M_teacher" @click="saveNavState('/M_teacher')">
              <template slot="title">
                <i class="el-icon-user"></i>
                <span>教员信息</span>
              </template>
            </el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>
      <!--   右侧内容主体     -->
      <el-main>
        <!--          路由占位符-->
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  name: "Ad_home",
  data(){
    return{
      //是否折叠
      isCollapse:false,
      //被激活的链接
      activePath:''
    }
  },
  created(){
    this.activePath = window.sessionStorage.getItem('activePath')
  },
  methods:{

    //点击按钮实现菜单的折叠与展开
    toggleCollapse(){
      this.isCollapse = !this.isCollapse
    },
    //保存链接的激活状态
    saveNavState(activePath){
      window.sessionStorage.setItem('activePath',activePath)
      this.activePath = activePath
    }
  },

}
</script>

<style scoped>
.home_container{
  height: 100%;
}
.el-header{
  background-color: #373D41;
  display: flex;
  justify-content: space-between;
  padding-left: 0;
  align-items: center;
  color: #fff;
  font-size: 20px;
}
.el-header>div{
  display: flex;
  align-items: center;
}
span{
  margin-left: 15px;
}
.el-aside{
  background-color: #333744;
}
.el-menu{
  border-right: none ;
}
.el-main{
  background-color: #EAEDF1;
}
.toggle-button{
  background-color: #4A5064;
  font-size: 10px;
  line-height: 44px;
  color: #fff;
  text-align: center;
  cursor: pointer;
}
</style>
